<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>Client Registration Manager</title>
<style type="text/css">
body {
	font-family: sans-serif;
}

.data,.data td {
	border-collapse: collapse;
	width: 100%;
	border: 1px solid #aaa;
	margin: 2px;
	padding: 2px;
}

.data 
 th {
	font-weight: bold;
	background-color: #5C82FF;
	color: white;
}
</style>
</head>
<!-- <body> -->

<!-- <h2>Client Manager</h2> -->
<!-- <h1>Add Client</h1> -->

<%-- <form:form method="post" action="add.html" commandName="client"> --%>

<!-- 	<table> -->
<!-- 	<tr> -->
<%-- 		<td><form:label path="user.firstname"><spring:message code="label.firstname"/></form:label></td> --%>
<%-- 		<td><form:input path="user.firstname" /></td>  --%>
<!-- 	</tr> -->
<!-- 	<tr> -->
<%-- 		<td><form:label path="user.lastname"><spring:message code="label.lastname"/></form:label></td> --%>
<%-- 		<td><form:input path="user.lastname" /></td> --%>
<!-- 	</tr> -->
<!-- 	<tr> -->
<%-- 		<td><form:label path="user.userName"><spring:message code="label.userName"/></form:label></td> --%>
<%-- 		<td><form:input path="user.userName" /></td> --%>
<!-- 	</tr> -->
<!-- 	<tr> -->
<%-- 		<td><form:label path="user.password"><spring:message code="label.telephone"/></form:label></td> --%>
<%-- 		<td><form:input path="user.password" /></td> --%>
<!-- 	</tr> -->
<!-- 	<tr> -->
<%-- 		<td><form:label path="user.gender"><spring:message code="label.gender"/></form:label></td> --%>
<%-- 		<td><form:input path="user.gender" /></td> --%>
<!-- 	</tr> -->
<!-- 	<tr> -->
<%-- 		<td><form:label path="user.newsletter"><spring:message code="label.newsletter"/></form:label></td> --%>
<%-- 		<td><form:input path="user.newsletter" /></td> --%>
<!-- 	</tr> -->

<!-- 	<tr> -->
<!-- 		<td colspan="2"> -->
<%-- 			<input type="submit" value="<spring:message code="label.addclient"/>"/> --%>
<!-- 		</td> -->
<!-- 	</tr> -->
<!-- </table>	 -->
<%-- </form:form> --%>


<!-- <h3>Clients</h3> -->
<%-- <c:if  test="${!empty clientList}"> --%>
<!-- <table class="data"> -->
<!-- <tr> -->
<!-- 	<th>First Name</th> -->
<!-- 	<th>Last Name</th> -->
<!-- 	<th>User Name</th> -->
<!-- 	<th>Password</th> -->
<!-- 	<th>Gender</th> -->
<!-- 	<th>Newsletter</th> -->

<!-- 	<th>&nbsp;</th> -->
<!-- </tr> -->
<%-- <c:forEach items="${clientList}" var="client"> --%>
<!-- 	<tr> -->
<%-- 		<td>${client.lastname}, ${client.firstname} </td> --%>
<%-- 		<td>${client.userName}</td> --%>
<%-- 		<td>${client.password}</td> --%>
<%-- 		<td>${client.gender}</td> --%>
<%-- 		<td>${client.newsletter}</td> --%>
<%-- 		<td><a href="delete/${client.clientId}">delete</a></td> --%>
<!-- 	</tr> -->
<%-- </c:forEach> --%>
<!-- </table> -->
<%-- </c:if> --%>


<!-- </body> -->
<!-- </html> -->



<body>
	<h1>Add client</h1>

	<c:url var="viewClientsUrl" value="/clients.htm" />
	<a href="${viewClientsUrl}">Show all Clients</a>
	<br />
	<br />
	<c:url var="saveClientUrl" value="/clients/save.htm" />
	
	<form:form modelAttribute="client" method="POST"
		action="${saveClientUrl}" commandName="client">

		<table>
			<tr>
				<td><form:label path="firstName">
						<spring:message code="label.firstname" />
					</form:label></td>
				<td><form:input path="firstName" /></td>
			</tr>
			<tr>
				<td><form:label path="lastName">
						<spring:message code="label.lastname" />
					</form:label></td>
				<td><form:input path="lastName" /></td>
			</tr>
			<tr>
				<td><form:label path="userName">
						<spring:message code="label.username" />
					</form:label></td>
				<td><form:input path="userName" /></td>
			</tr>
			<tr>
				<td><form:label path="password">
						<spring:message code="label.password" />
					</form:label></td>
				<td><form:input path="password" /></td>
			</tr>
			<tr>
				<td><form:label path="gender">
						<spring:message code="label.gender" />
					</form:label></td>
				<td><form:input path="gender" /></td>
			</tr>
			<tr>
				<td><form:label path="newsletter">
						<spring:message code="label.newsletter" />
					</form:label></td>
				<td><form:input path="newsletter" /></td>
			</tr>

			<tr>
				<td colspan="2"><input type="submit"
					value="<spring:message code="label.addclient"/>" /></td>
			</tr>
		</table>
	</form:form>


	<h3>Clients</h3>
	<c:if test="${!empty clientList}">
		<table class="data">
			<tr>
				<th>First Name</th>
				<th>Last Name</th>
				<th>User Name</th>
				<th>Password</th>
				<th>Gender</th>
				<th>Newsletter</th>

				<th>&nbsp;</th>
			</tr>
			<c:forEach items="${clientList}" var="client">
				<tr>
					<td>${client.lastName}, ${client.firstName}</td>
					<td>${client.userName}</td>
					<td>${client.password}</td>
					<td>${client.gender}</td>
					<td>${client.newsletter}</td>
					<td><a href="delete/${client.clientId}">delete</a></td>
				</tr>
			</c:forEach>
		</table>
	</c:if>
</body>